﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MemberUser/MemberMaster.master" AutoEventWireup="true" CodeBehind="MyAddress.aspx.cs" Inherits="ZLCMS.Web.MemberUser.MyAddress" %>

<%@ Import Namespace="ZLCMS.Business.Util" %>
<%@ MasterType VirtualPath="~/MemberUser/MemberMaster.Master" %>
<%@ Register src="UC/MemberCategory.ascx" tagname="MemberCategory" tagprefix="uc1" %>
<%@ Register src="UC/Ad_Right.ascx" tagname="Ad_Right" tagprefix="uc2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script src="/js/xheditor/xheditor-zh-cn.min.js" type="text/javascript"></script>
<script>
    $(function () {
        if ('<%=Request["msg"] %>' != "") {
            alert('<%=Request["msg"] %>');
        }
    });
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
 
<!--wrapper start-->
<div id="wrapper">
	<!--left start-->
    <div class="shop_left">
        <uc1:MemberCategory ID="MemberCategory1" runat="server" />
    </div>
    <!--left end-->
    
    <!--centent start-->
    <div class="shop_centent">
    	<h2>收货地址管理</h2>
        <% if (_addrId == 0)
           { %>
        <div class="box">
            <div class="cent_top"><a href="/MemberUser/MyAddress.aspx?id=-1">新增收货地址</a>您已新建<span><%= rpt_address.Items.Count%></span>个收货地址，最多可创建<span>20</span>个</div>
                <asp:Repeater ID="rpt_address" runat="server">
                <ItemTemplate>
                 <div class="address">
            	<div class="title"><%# Eval("Status").ToString() == "1"? "默认地址" : "<a  href='/MemberUser/MyAddress.aspx?opt=setdefault&id=" + Eval("Id") + "'>设为默认</a>"%><span><a href="/MemberUser/MyAddress.aspx?opt=edit&id=<%# Eval("Id") %>">修改地址</a><a href="/MemberUser/MyAddress.aspx?opt=del&id=<%# Eval("Id") %>">删除</a></span></div>
                <ul>
                	<li><label>收货人：</label><%# Eval("Receiver") %></li>
                    <li><label>地址：</label><%# ParamKit.GetValue("Province", Eval("Province"), "") + "-" + ParamKit.GetValue("City", Eval("City"), "") + "-"+ParamKit.GetValue("Area", Eval("Area"), "")+"_"+ Eval("Address")%></li>
                    <li><label>手机：</label><%# Eval("Phone") %></li>
                </ul>
            </div>
                </ItemTemplate>
                </asp:Repeater>
          
        </div>
           <%} else{%>
                        <div class="box">
                <div class="regist_box no_bxd"  style="height:750px;">
                    <div class="r_left">
                        <div class="tabs_box">
                            <div class="con1">
                                <form id="Form1" runat="Server" class="registerform">
                                <div class="inp">
                                    <label>
                                        收货人姓名</label><asp:TextBox ID="tb_name" name="tb_name" runat="server" MaxLength="16" datatype="s2-16" errormsg="请填写2-16位字符！" nullmsg="请请填写6-16位字符！" >
                                      
                                        </asp:TextBox><div
                                                class="clear">
                                            </div>
                                </div>
                                <div class="checktip">
                                    <span class="Validform_checktip"></span>
                                </div>
                                    <div class="inp">
                                    <label>
                                        手机号码</label><asp:TextBox ID="tb_phone" runat="server" MaxLength="16" name="tb_phone"   errormsg="请输入正确的手机号码！" nullmsg="请输入手机号码！" datatype="m">    </asp:TextBox><div
                                                class="clear">
                                            </div>
                                </div>
                                    <div class="checktip">
                                    <span class="Validform_checktip"></span>
                                </div>
                                <div class="inp">
                                    <label>
                                        省份/直辖市</label>
                                          <select  name="province" datatype="*" command-param='Province'  runat="server"
                id="sel_province" class="area" >
                <%--<asp:Repeater ID="rptProvince" runat="server">
                    <ItemTemplate>
                        <option value='<%# Eval("Code") %>'>
                            <%# Eval("Name") %></option>
                    </ItemTemplate>
                </asp:Repeater>--%>
            </select>
                   <div class="checktip">
                                    <span class="Validform_checktip"></span>
                                </div>
                                </div>
                                
                                <div class="inp">
                                    <label>
                                        城市</label>
                                            <select   command-param='City'  datatype="*"   runat="server"   name="city"  id="sel_city" class="area" >
                <option value="-1">请选择</option>
            </select>
             <%--   <asp:DropDownList  ID="sel_city" name="city" datatype="*"     class="area"  runat="server" >
                <asp:ListItem Value
                ="-1">请选择</asp:ListItem>
                                </asp:DropDownList>--%>
                                        <div       class="clear">
                                            </div> <div class="checktip">
                                    <span class="Validform_checktip"></span>
                                </div>
                                </div>
                                <div class="inp">
                                    <label>
                                        区/县</label>
                                          <select   command-param='Area'   datatype="*"    runat="server"
                name="area" id="sel_area" class="area" >
                <option value="-1">请选择</option>
            </select>
           <%-- <asp:DropDownList  datatype="*"    runat="server"
                 id="sel_area" class="area">
                
                                </asp:DropDownList>--%>
                                        <div      class="clear">
                                            </div>
                                </div>
                                  <div class="inp">
                                    <label>详细地址</label>
                            <asp:TextBox ID="tb_address" runat="server" name="tb_address"   > </asp:TextBox>
                                           <div       class="clear">
                                            </div>
                                </div>
                                  <div class="inp1">
                                     <p>
                                         <asp:CheckBox ID="ckb_default_address" name="ckb_default_address" runat="server" />
                                       <label for='<%=ckb_default_address.ClientID  %>'> 设为默认地址</label></p> 
                                        <div    class="clear">  </div>
                                </div>
                                <p class="tijiao">
                                    <asp:Button ID="Button1" class="submit" runat="server" Text="确认修改" OnClick="Button1_Click" />  </p>
                                </form>
                            </div>
                        </div>
                    </div>
                    <div class="clear">
                    </div>
                </div>
            </div>

           <%} %>
    </div>
 
    <!--centent end-->
    
    <!--right start-->
    <div class="shop_right">
        <uc2:Ad_Right ID="Ad_Right1" runat="server" />
    </div>
    <!--right end-->
    
    <div class="clear"></div>
</div>
    <script src="/js/Common.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
       
                    //Bind Cities when Provinces selected change
                    $("select#<%=sel_province.ClientID %>").change(function () {
                        var provinceCode = $("select#<%=sel_province.ClientID %>").val();
                        $("select#<%=sel_province.ClientID %>").ExecuteCommand({
                            successCallBack: function (result) {
                                //判断是否处于页面初始化状态
                                var binitialize = false;

                                if (result) {
                                    var _html = '<option value="-1" >请选择</option>';
                                    for (var i = 0; i < result.length; i++) {
                                        if ('<%=  _memberAddress==null?"":_memberAddress.City  %>' == result[i].Key) {
                                            binitialize = true;
                                            _html += '<option selected="selected" value=' + result[i].Key + '>' + result[i].Value + '</option>';
                                        }
                                        else {
                                            _html += '<option value=' + result[i].Key + '>' + result[i].Value + '</option>';
                                        }
                                    }
                                    $("select#<%=sel_city.ClientID %>").empty().append(_html);
                                    if(binitialize){
                                        $("select#<%=sel_city.ClientID %>").trigger('change');
                                    }
                                }
                            },
                            errorCallback: function (errorCode, msg) {
                                alert(msg);
                            }
                        }, 'LoadAddress', { Category: 'City', KeyValuePairString: 'Province:' + provinceCode });
                    });
                    //Bind Areas when Cites selected change
                    $("select#<%=sel_city.ClientID %>").change(function () {
                        var CityCode = $("select#<%=sel_city.ClientID %>").val();
                        $("select#<%=sel_city.ClientID %>").ExecuteCommand({
                            successCallBack: function (result) {
                                if (result) {
                                    var _html = '<option value="-1" >请选择</option>';
                                    for (var i = 0; i < result.length; i++) {
                                        if ('<%=  _memberAddress==null?"":_memberAddress.Area  %>' == result[i].Key) {

                                            _html += '<option selected="selected" value=' + result[i].Key + '>' + result[i].Value + '</option>';
                                        }
                                        else {
                                            _html += '<option value=' + result[i].Key + '>' + result[i].Value + '</option>';
                                        }
                                    }
                                    $("select#<%=sel_area.ClientID %>").empty().append(_html);
                                }
                            },
                            errorCallback: function (errorCode, msg) {
                                alert(msg);
                            }
                        }, 'LoadAddress', { Category: 'Area', KeyValuePairString: 'City:' + CityCode });
                    });
                });

       window.onload = function () {
           if ('<%=  _memberAddress==null?"":_memberAddress.Province  %>' != '') {
               //            $('option[value=<%= _memberAddress==null?"":_memberAddress.Province %>]').attr("selected", "selected");
               //            $("select#1").change();

               $("select#<%=sel_province.ClientID %>").val('<%= _memberAddress==null?"":_memberAddress.Province  %>');
               $("select#<%=sel_province.ClientID %>").change();
               $(".registerform").openValidform();
           }
//           if ('<%= _memberAddress==null?"":_memberAddress.Status %>' == '1') {
//               $("input#ckmr").click();
//           }

       };
</script>
<!--wrapper end-->
</asp:Content>
